package cn.micai.base.concurrent;

/**
 * 描述：
 * <p>
 *
 * @author: 赵新国
 * @date: 2018/5/14 10:41
 */
public class SimulatedCAS {

    private int value;

    public synchronized int getValue() {
        return value;
    }

    public synchronized int compareAndSwap(int expectedValue, int newValue) {
        if (value == expectedValue) {
            value = newValue;
        }
        return value;
    }
}
